# 导包
import unittest
from api.home import HomeAPI

# 创建格式类
class TestHome(unittest.TestCase):

    # 前置处理
    def setUp(self) -> None:
        # 实例化接口类
        self.home_api = HomeAPI()

    # 后置处理
    def tearDown(self) -> None:
        pass

    # 获取轮播图
    def test01_banner(self):
        response = self.home_api.banner()
        # 打印响应结果
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertIn("轮播图", response.json().get("description"))

    # 获取专题栏位
    def test02_theme(self):
        response = self.home_api.theme()
        # 打印响应结果
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertIn("专题栏", response.json()[0].get("name"))

    # 获取最近新品
    def test03_recent(self):
        response = self.home_api.recent()
        # 打印响应结果
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertIn("芹菜", response.json()[0].get("name"))
